FROM node:lts-buster-slim

WORKDIR /hexo
VOLUME ["/hexo"]

EXPOSE 4000 

RUN npm install -g hexo-cli \
    && npm cache clean -f \
    && apt-get update \
    && apt-get install git -y \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# 创建相关目录和配置文件
RUN mkdir -p ~/.ssh && \
    chmod 0700 ~/.ssh && \
    touch ~/.ssh/id_rsa      && chmod 600 ~/.ssh/id_rsa && \
    touch ~/.ssh/id_rsa.pub  && chmod 644 ~/.ssh/id_rsa.pub && \
    touch ~/.ssh/known_hosts && chmod 644 ~/.ssh/known_hosts

COPY docker-entrypoint.sh /docker-entrypoint.sh

ENTRYPOINT ["/docker-entrypoint.sh"]

CMD ["/bin/bash"]
